gh-119670: Add force keyword only argument to shlex.quote#148846
gh-119670: Add force keyword only argument to shlex.quote#148846jb2170 wants to merge 15 commits intopython:mainfrom
force keyword only argument to shlex.quote#148846Conversation
There are propositions to add a single-quote-double-quote switch (pythongh-90630), so to avoid hiccups of people passing `force` as a positional and it being used for the single-double switch, we make kwargs kwargs-only.
Test special cases of strings that don't need quoting, do need quoting, do use `force`, don't use `force` etc. I've tried to be exhaustive.
…to `shlex.force`
|
|
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
The comments for why these tests exist can always be found in the git history Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Missed from last commit
Intended for another branch shlex-quote-typeerror Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
|
Looks ready (for review again?) to me 😎 |
picnixz
left a comment
There was a problem hiding this comment.
Minor tweaks but please add more tets with quotes inside.
a9e06cd to
e7bf496
Compare
|
Please avoid force-pushing. It's extremely hard to make reviews otherwise. |
…view Show off the default behavior as `force=False`
Try not to use don't and we're and should've etc apostrophes.
Add test to ensure string with single quote inside it (without which the string wouldn't need quoting) is quoted even though `force=False`.
e7bf496 to
e3d9b05
Compare
|
Sorry for the force pushes but the 'commit suggestions' commits on GitHub came through as CRLF formatted instead of LF. I don't know if that's a GitHub Microsoft issue,
|
|
I think it's a GH issue because other reviews had the same issue... |
|
Ready |
Closes #119670
Supersedes my out-of-date PR #119674
We use
forceinstead ofalwaysas a word more consistent with other programming jargon (like inrm -fthefis for 'force') as discussedCommits
shlex.quote's kwargs kwargs-only. Backwards compatible. There are propositions to add a single-quote-double-quote switch, which I'm ambivalent about, but to future-proof against hiccups of people passingforceas a positional and it ending up being used as the wrong kwarg, we make the kwargs kwargs-only, eg likejson.loads.As mentioned I'm also going to open
an issuea discussion thread aboutshlex.quotereturning"''"for falsey non-str data. This PR and that discussion seem independent of each other, that is this PR doesn't need to be held back until that discussion is addressed.forcekeyword argument #119670📚 Documentation preview 📚: https://cpython-previews--148846.org.readthedocs.build/